﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XinYi.CrookedShow.Core;
using XinYi.CrookedShowMode;

namespace XinYi.CrookedTopShow.DAL
{
    /// <summary>
    /// 注册
    /// </summary>
    public class RegisterRepository
    {
        #region 注册用户信息
        public int AddUserInfo(UserInfo userInfo)
        {
            string sql = @"INSERT INTO [CrookedShow].[dbo].[User]
                   ([UserName]
                   ,[Pwd]
                   ,[Phone]
                   ,[CreateTime]
                   ,[UpdateTime])
             VALUES
                   (UserName=@UserName, 
                   Pwd=@Pwd,
                   Phone=@Phone,
                   CreateTime=" + DateTime.Now + ", UpdateTime=" + DateTime.Now + ")";
            return Convert.ToInt32(DapperHelper<UserInfo>.Execute(sql, userInfo));
        } 
        #endregion

        #region 查询用户名
        public int SelUserName(UserInfo userInfo)
        {
            string sql = "select COUNT(1) from [User] where UserName=@UserName";
            return Convert.ToInt32(DapperHelper<UserInfo>.QuerySingle(sql, userInfo));
        } 
        #endregion

        #region 查询电话号码
        public int SelUserPhone(UserInfo userInfo)
        {
            string sql = "select COUNT(1) from [User]  where Phone=@Phone";
            return Convert.ToInt32(DapperHelper<UserInfo>.QuerySingle(sql, userInfo));
        } 
        #endregion
    }
}